<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title> </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="stylesheet" href="../css/admin.css" media="all">
    <link rel="stylesheet" href="../css/layui.css" media="all">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
</head>

<body>
   <form class="layui-form" action="">
    <div class="layui-form-item" style="display:none;">
    <label class="layui-form-label"></label>
    <div class="layui-input-block">
      <input type="text" id = "adminId" name="adminId" required  lay-verify="required" autocomplete="off" class="layui-input">
    </div>
  </div>
  <br />
  <div class="layui-form-item">
    <label class="layui-form-label">管理员名称</label>
    <div class="layui-input-block">
      <input type="text" id = "adminName" name="adminName" required  lay-verify="required" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">密码</label>
    <div class="layui-input-block">
      <input type="text" id = "password" name="password" required  lay-verify="required" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">客服电话</label>
    <div class="layui-input-block">
      <input type="text" id = "adminAccount" name="adminAccount" required  lay-verify="required"  autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">注册时间</label>
    <div class="layui-input-block">
      <input type="text" id = "adminCreationTime" name="adminCreationTime" required  lay-verify="required" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">登录时间</label>
    <div class="layui-input-block">
      <input type="text" id = "adminLocationTime" name="adminLocationTime" required  lay-verify="required" autocomplete="off" class="layui-input">
    </div>
  </div>
  
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
    </div>
  </div>
</form>
</body>
<script type="text/javascript" src="../js/static.js"></script>
<script type="text/javascript" src="../js/global.js"></script>
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="../layui/layui.js"></script>
<script>
$(function(){
  $.ajax({
                async:false,
               url: preUrl+'/admin/info',
               type: 'POST',
               "processData": false,
               "contentType": false,

            })
            .done(function(res){
              if(res.code==100){
                let list=res.object;
                $("#adminId").attr("value",list.adminId);
                $("#adminName").attr("value",list.adminName);
                $("#password").attr("value",list.password);
                $("#adminAccount").attr("value",list.adminAccount);
                $("#adminCreationTime").attr("value",list.adminCreationTime);
                $("#adminLocationTime").attr("value",list.adminLocationTime);

              }else{
                layer.msg(res.extend.msg);
              }
            })
})


layui.use('form', function(){
  var form = layui.form;
  
  //监听提交
  form.on('submit(formDemo)', function(data){

    var form = new FormData();
    form.append("adminId", data.field.adminId);
    form.append("adminName", data.field.adminName);
    form.append("password", data.field.password);
    form.append("adminAccount", data.field.adminAccount);
    form.append("adminCreationTime", data.field.adminCreationTime);
    form.append("adminLocationTime", data.field.adminLocationTime);
    $.ajax({
                async:false,
               url: preUrl+'/admin/update',
               type: 'POST',
               "processData": false,
               "contentType": false,
               data:form,

            })
            .done(function(res){
              if(res.code==100){
                window.location.reload();
              }else{
                layer.msg(res.extend.msg);
              }
            })
  });
});



</script>

</html>